/**
 * Ext.util.TaskRunner
 * Provides the ability to execute one or 
 * more arbitrary tasks in a multithreaded manner. 
 * Generally, you can use the singleton 
 * Ext.TaskManager instead, but if needed, 
 * you can create separate instances of TaskRunner. 
 * Any number of separate tasks can be started at any time 
 * and will run independently of each other. 
 */
(function(){
	Ext.onReady(function(){
		//取得一个TaskRunner实例对象
		var runner = new Ext.util.TaskRunner();
		//定义一个执行的任务
		var task = {
			run: function() {
				Ext.getDom("show").value = Ext.util.Format.date(new Date(), "Y-m-d h:m:s");
			},
			interval: 1000  //处理函数执行的时间间隔
		};
		runner.start(task);  //启动线程
		
		//给按钮添加单击事件
		Ext.get("bnt1").on("click", function() {
			runner.stop(task);  //终止正在执行的线程
		});
	});
})();

